require 'mysql'

my = Mysql.new("10.10.13.155", "root", "iesb", "TESTE_UNREALDB")

count = 0

real_start = Time.now
times = []

500.times do |i|
  start = Time.now
  str = "INSERT INTO FOTO(foto_id, URL) VALUES(" + i.to_s + ",'/home/joao/pictures')"
  if my.query(str)
    puts "Erro ao inserir foto " + i.to_s
    puts str
  end
  100.times do |t|
    count += 1
    str2 = "INSERT INTO COMENTARIO(comentario_id, foto_fk, texto) VALUES(" + count.to_s + "," + i.to_s + ", 'SUPER COMENTARIO')"
    if my.query(str2)
      puts "Erro ao inserir comentario " + count.to_s
      puts str2
    end
  end
  times << (Time.now - start)
end

puts "Total: " + (Time.now - real_start).to_s
times.each{|t| puts t.to_s }

my.close
